package com.oracle.containers.queue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 * @author zhouyanxiang
 * @create 2020-08-2020/8/16-21:59
 * ArrayBlockingQueue 是基于数组结构实现的有界堵塞队列
 */
public class ArrayBlockingQueueReview {

    static BlockingQueue<String> arrayBlockingQueue = new ArrayBlockingQueue<>(20);


    public static void main(String[] args) throws InterruptedException {
        arrayBlockingQueue.put("Tom");
        arrayBlockingQueue.put("KangKang");
        arrayBlockingQueue.put("Mike");
        System.out.println(arrayBlockingQueue.size());
        System.out.println(arrayBlockingQueue.peek());
        try {
            System.out.println(arrayBlockingQueue.take());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
